<?php
class ImageUtil {
  
  /**
   * resize image and set watermark
   * 
   * @param string $img_path
   */
  public static function resizeImage($imgPath) {
    $tmpPathArr = explode('/', $imgPath);
    $imgName    = $tmpPathArr[count($tmpPathArr)-1];
    $tmpImgArr  = explode('_', $imgName);
    $id         = $tmpImgArr[0];
    $tmpPathArr = explode('.', $imgName);
    $imgExt     = $tmpPathArr[count($tmpPathArr)-1];
    $over_lay_path = null;
    
    # get image object
    $img = new sfImage($imgPath);
    $width = $img->getWidth();
    $height = $img->getHeight();
    
    $newWidth   = sfConfig::get('app_slide_image_width'); error_log($newWidth);
    $newHeight  = ($newWidth/$width) * $height; error_log($newHeight);
    $img->resize($newWidth,$newHeight);
    $img->save();
    unset ($img);
  }
}

?>
